package com.bos.common;

import java.util.List;

/**
 * Created by sxy on 2016/7/28.
 */
public class PageData<T> {
    public static final int DEFAULTPAGESIZE = 10;
    public int pageSize = DEFAULTPAGESIZE;
    public int totalPages = 1;
    private int pageNo;
    private int total;
    private List<T> data;

    public PageData(List<T> data, int total, int pageSize, int pageNo) {
        this.total = total;
        this.data = data;
        if (pageSize != 0) {
            if (total % pageSize == 0) {
                this.totalPages = total / pageSize;
            } else {
                this.totalPages = total / pageSize + 1;
            }
        }

        this.pageNo = pageNo;
        if (total == 0) {
            this.pageNo = 1;
        }
        if (pageSize != DEFAULTPAGESIZE) {
            this.pageSize = pageSize;
        }
    }

    public PageData(List<T> data) {
        this.data=data;
    }
    public PageData() {
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
